
<!--
All rights Reserved, Designed By www.youyacao.com
@Description:邮箱配
@author:成都市一颗优雅草科技有限公司
@version V4.2
注意：本前端源码遵循 MIT开源协议本内容仅限于个人参考，禁止用于其他的商业用途
需要商业用途或者定制开发等可访问songshu.youyacao.com   联系QQ:422108995 23625059584
开源gitee地址：https://gitee.com/youyacao/songshu-video-page
 -->


<template>
  <div>
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>
          <i class="el-icon-lx-calendar"></i> 站点配置
        </el-breadcrumb-item>
        <el-breadcrumb-item>邮件配置</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="container">
      <div class="form-box">
        <el-form ref="form" :model="form" label-width="200px">
          <el-form-item label="注册验证码模板 ">
            <el-input v-model="form.mail_template" placeholder="如:【优雅草】您的验证码是：{验证码}，请在10分钟内输入。请勿告诉其他人。"></el-input>
          </el-form-item>
          <el-form-item label="发信用户名">
            <el-input v-model="form.mail_user"></el-input>
          </el-form-item>
          <el-form-item label="发信密码">
            <el-input v-model="form.mail_pass" type="password"></el-input>
          </el-form-item>
          <el-form-item label="发件人名称">
            <el-input v-model="form.mail_name"></el-input>
          </el-form-item>
          <el-form-item label="smtp地址">
            <el-input v-model="form.mail_smtp" placeholder="一般为:smtp.qq.com|smtp.163.com等"></el-input>
          </el-form-item>
          <el-form-item label="发送间隔时间(毫秒)">
            <el-input v-model="form.mail_sleep_time"></el-input>
          </el-form-item>
          <el-form-item label="有效时间(毫秒)">
            <el-input v-model="form.mail_life_time"></el-input>
          </el-form-item>
          <el-form-item :label="'最大错误次数(防止暴力破解)'">
            <el-input v-model="form.mail_err_count"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit">提交</el-button>
            <el-button>取消</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import qs from 'Qs'
export default {
  name: 'baseform',
  data () {
    return {
      form: {}
    }
  },
  created () {
    this.getData()
  },
  methods: {
    getData () {
      this.$api.config.get({}).then(res => {
        this.form = res.data
      })
    },
    onSubmit () {
      var data = []
      for (let item in this.form) {
        data[`config[${item}]`] = this.form[item]
      }
      console.log(data)
      this.$api.config.set(qs.stringify(data)).then(res => {
        console.log(res.data)
      })
      this.$message.success('提交成功！')
    }
  }
}
</script>
